package com.dhl.observer.improve;

/**
 * @title: Client
 * @Author danghailiang
 * @Date: 2022/8/22 10:20
 * @Version 1.0
 */
public class Client {
    public static void main(String[] args) {
        // 初始化天气预报
        WeatherData weatherData = new WeatherData(10,20,30);

        // 添加接收者
        Observer currentCondition = new CurrentCondition();

        weatherData.register(currentCondition);
        weatherData.register(new BaiDu());

        // 通知接收者
        weatherData.notifyObserver();
        
        // 移除接受者
        weatherData.remove(currentCondition);

        // 修改天气
        weatherData.setPressure(30);

        // 再次通知接收者
        weatherData.notifyObserver();
    }
}
